package ch.exm.storm.conditions;


public class And extends AbstractCompositeCondition {

	public And(Condition... conditions) {
		super(conditions);
	}
	
	public And(Iterable<Condition> conditions) {
		super(conditions);
	}

	public boolean matches(Object object) {
		for (Condition condition : conditions) if (!condition.matches(object)) return false;
		return true;
	}

	@Override
	public And addCondition(Condition condition) {
		return and(condition);
	}
	
	@Override
	protected String getConditionKeyword() {
		return " and ";
	}

	@Override
	protected boolean isShortcutCondition() {
		return false;
	}
	
	@Override
	public And and(Condition condition) {
		if (condition instanceof And) for (Condition c : (And)condition) addCondition(c);
		else super.addCondition(condition);
		return this;
	}
}
